#ifndef KLogger_H
#define KLogger_H
#include <string>
#include <stdio.h>
#include <cassert>
#include <iostream>
#include <fstream>
#include <time.h>
#include <stdarg.h>

using std::string;


//some convenient defines to make it simple to use :)
#ifdef WIN32
#define ShowStatus(...)  Logger::Instance()->Log(Logger::MSG_STATUS, __VA_ARGS__)
#define ShowError(...) Logger::Instance()->Log(Logger::MSG_ERROR, __VA_ARGS__)
#define ShowWarning(...) Logger::Instance()->Log(Logger::MSG_WARNING, __VA_ARGS__)
#define ShowDebug(...) Logger::Instance()->Log(Logger::MSG_DEBUG, __VA_ARGS__)
#else
//only support c99 standard, gcc standard va_list defines will be added later.
#endif


class Logger
{
public:
	static const int BUF_SIZE = 2048;
	enum MSG_TYPE {
		MSG_NONE,
		MSG_STATUS,
		MSG_SQL,
		MSG_INFORMATION,
		MSG_NOTICE,
		MSG_WARNING,
		MSG_DEBUG,
		MSG_ERROR,
		MSG_FATALERROR
	};

private:
	Logger();
public:
	static Logger* Instance();
	bool __cdecl Log(MSG_TYPE type, const char* pstrFmtString, ...);
protected:
	bool Log(MSG_TYPE type, const string& strInfo);
	string FileHeader(const std::string& p_title);
	string DateStamp();
	string TimeStamp();

protected:
	std::fstream m_fpLog;
};



#endif // KLogger_H